<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>
<html lang="en">
<body class="wysihtml5-supported">
	<div id="content">
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span12">
					<div class="widget-box">
						<div class="widget-title">
							<h5>详情</h5>
						</div>
						<div class="widget-content nopadding">
							<form id="userForm" action="" method="post" class="form-horizontal">
								<div class="control-group">
									<label class="control-label">UserId :</label>
									<div class="controls">
										<span class="span4" name="userName" ></span>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">UserName :</label>
									<div class="controls">
										<span class="span4" name="userName" ></span>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">Email :</label>
									<div class="controls">
										<span class="span6" name="email" ></span>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">certNo :</label>
									<div class="controls">
										<span class="span4" name="certNo" ></span>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">mobile :</label>
									<div class="controls">
										<span class="span5" name="mobile" ></span>
									</div>
								</div>
								<div class="form-actions">
									<button type="button" class="btn btn-danger " style="float:right;margin-left:10px;"  onclick="del(${param.userId})">删除</button>
									<button id="opener" type="button" class="btn btn-warning" style="float:right;margin-left:10px;"  onclick="edit(${param.userId})">修改</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div id="modelDialog" class="modal hide fade in" style="display:none;">
		<div class="modal-header">
			<a class="close" data-dismiss="modal">x</a>
			<h4>操作提示</h4>
		</div>
		<div class="modal-body">
			<h4>确认删除该项记录吗？</h4>
		</div>
		<div class="modal-body">
			<button id="confirm" type="button" class="btn btn-success">确认</button>
			<button  type="button class="btn btn-default" data-dismiss="modal">关闭</button>
		</div>
	</div>
	
	<script>
	
	    var _id = "";
		//初始化表单数据
		$(document).ready(function(){
			_id = "${param.userId}";
			if(_id != null && _id != ""){
				$.ajax({
					url:"<%=path%>/user/get",
				    data:{"userId":_id},
				    type:"post",
				    success:function(text){
				    	if(text.success){
				    		var _data = text.data ;
					    	$("#userForm").find("span").each(function(){
					    		_this = $(this) ;
					    		_name = _this.attr("name") ;
					    		if(_name!=null){
					    			for(key in _data){
					    				if(_name == key){
					    					_this.html(_data[key]);
					    				}
					    			}
					    		}
					        });
				    	}else{
				    		//查询无结果时返回原查询页面，并返回标识result=null表示无查询结果
				    		window.location.href="<%=path%>/user/query?result=null";
				    	}
				    }
				});
			}
		});
		
 	    //编辑
 		function edit(id){
 	    	window.location.href="<%=path%>/user/form?id="+id;
 		}   
 	    
 		//删除
 		function del(id){		
			$("#modelDialog").modal();
			$("#confirm").click(function(){
     			$.ajax({
     				url:"<%=path %>/user/del",
     				data:{"userId":id},
     				type:"post",
     				success:function(text){
     					if(text.success){
     						C.gritter("删除成功！");
     						history.go(-1);	
     					}else{
     						C.gritter("删除失败！");
     					}
     				}
     			});
			});
 		}

	</script>
</body>
</html>

